package com.network.dao;

import com.network.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * 用户管理
 * @author peng
 * @return
 */
@Repository
public interface UserDao extends JpaRepository<User,Long>, JpaSpecificationExecutor<User>
{

    /**
     * 用户登录
     */
    @Query("select u from  User  u left  join u.dept d left join u.roles r where  u.username=:userName and u.password=:password")
    User findByUsernameAndPassword(@Param("userName") String userName, @Param("password") String password);


    User findFirstByUsername(String userName);

    User findFirstByUsernameAndDelFlagEquals(String userName, Integer delFlag);



}
